<?php
/**
 * Notes:
 * User: LiaoHong
 * Date: 2025/10/16
 * Time: 16:48
 **/
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use App\Http\Requests\User\UserRequest;
use App\Services\User\UserService;
use Illuminate\Http\Request;

class UserController extends Controller
{

    /** @var UserService */
    private UserService $userService;

    public function __construct(UserService $service)
    {
        $this->userService = $service;
    }

    /**
     * @Notes:获取用户信息
     * @param UserRequest $request
     * @author: Liao Hong
     * @Time: 2025/10/21   14:34
     * @Interface getInfo
     */
    public function getInfo(UserRequest $request)
    {
        return success($this->userService->getInfo());
    }

    /**
     * @Notes:获取路由地址
     * @author: Liao Hong
     * @Time: 2025/10/21   15:55
     * @Interface getRouters
     */
    public function getRouters()
    {
        return success($this->userService->getRouters());
    }

    /**
     * @Notes:获取单条数据
     * @param UserRequest $request
     * @return \Illuminate\Http\JsonResponse
     * @author: Liao Hong
     * @Time: 2025/10/21   16:30
     * @Interface getRow
     */
    public function getRow(UserRequest $request)
    {

        $data = $request->input();
        return success($this->userService->getRow($data));
    }
    /**
     * @Notes:添加用户
     * @author: Liao Hong
     * @Time: 2025/10/20   13:22
     * @Interface add
     */
    public function add(UserRequest $request)
    {
        $data = $request->input();
        return success($this->userService->add($data));
    }
    /**
     * @Notes:修改用户
     * @author: Liao Hong
     * @Time: 2025/10/20   13:22
     * @Interface add
     */
    public function update(UserRequest $request)
    {
        $data = $request->input();
        return success($this->userService->update($data));
    }
    /**
     * @Notes:删除用户
     * @author: Liao Hong
     * @Time: 2025/10/20   13:22
     * @Interface add
     */
    public function delete(UserRequest $request)
    {
        $data = $request->input();
        return success($this->userService->delete($data));

    }
    /**
     * @Notes:用户列表
     * @author: Liao Hong
     * @Time: 2025/10/20   13:22
     * @Interface add
     */
    public function list(UserRequest $request)
    {
        $data = $request->input();
        return success($this->userService->list($data));
    }

}
